package com.rfid.analysis;

/**
 * @author Administrator
 * @date 2020/10/21
 */
public class HandlerChain {
    private Handler head;
    private Handler tail;

    public HandlerChain addHandler(Handler handler) {
        if (head == null) {
            head = handler;
            tail = handler;
            return this;
        }
        tail.setNext(handler);
        tail = handler;
        return this;
    }

    public void handle(Message message) {
        if (head != null) {
            head.handleRequest(message);
        }
    }

    public Handler getHead() {
        return head;
    }
} 